<template>
  <div class="contents">
    <PanelTitle title="土地资源" />
    <div class="infoPanel mt">
      <div>
        <div class="infoTitle">地块总量</div>
        <div class="infoNumss">
          <span class="infoNum">{{ data.landStatist.num }}</span>
          <span class="infoUnit">块</span>
        </div>
      </div>
      <div>
        <div class="infoTitle">地块面积</div>
        <div class="infoNumss">
          <span class="infoNum">{{ data.landStatist.acreage }}</span>
          <span class="infoUnit">亩</span>
        </div>
      </div>
      <div>
        <div class="infoTitle">太子参种植地块</div>
        <div class="infoNums">
          <span class="infoNum">{{ data.plantTaskStatist.landNum}}</span>
          <span class="infoUnit">块</span>
        </div>
        <div class="infoSub">占比 {{ data.plantTaskStatist.landNumRatio}}%</div>
      </div>
      <div>
        <div class="infoTitle">太子参种植面积</div>
        <div class="infoNums">
          <span class="infoNum">{{ data.plantTaskStatist.acreage}}</span>
          <span class="infoUnit">亩</span>
        </div>
        <div class="infoSub">占比 {{ data.plantTaskStatist.acreageRatio}}%</div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { onMounted, ref, watch } from "vue";
import PanelTitle from "../../component/PanelTitle.vue";
import http from "@/api/http";
import { env } from "@/utils/env";
import type { Base } from "@/types/Base";
import { useBaseStore } from "@/stores/base";
const baseStore = useBaseStore()
const props = defineProps<{
  base: Base
}>()
const data = ref<any>({landStatist: '', plantTaskStatist: ''})
const init = async () => {
  let res = await http<any>({
    url: env.VITE_ZHER_DATA_CENTER + "/base/land/res/statist",
    method: "get",
    params: { 
      baseId: props.base.id,
      year: new Date().getFullYear()
    },
  });
  
  data.value = res.data
  baseStore.plantTaskStatist = res.data.plantTaskStatist
}

watch(() => props.base, () => {
  init()
} )

onMounted(async () => {
  
  
 
})
</script>

<style scoped lang="scss">
.contents {
  background: linear-gradient(to bottom,
      rgba(5, 79, 99),
      rgba(5, 79, 99, 0.1),
      rgba(5, 79, 99));
  border-radius: vh(8);
  border: vh(1) solid rgba(6, 112, 180, 1);

  .mt {
    margin-top: vh(-40);
  }
}

.infoPanel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: vh(10) vw(15) 0px;

  >div {
    box-sizing: border-box;
    width: vw(160);
    height: vh(80);
    background: rgba(9, 36, 44, 0.4);
    border: vh(1) solid #43e7ff;
    padding: 0 vw(20) 0px;
    margin-bottom: vh(10);
  }

  .infoTitle {
    color: #fff;
    font-size: vh(10);
    line-height: vh(30);
  }

  .infoNums {
    line-height: vh(20);
  }

  .infoNumss {
    line-height: vh(36);
  }

  .infoNum {
    color: #adffd7;
    font-size: vh(26);
    font: SourceHanSansCN-Bold;
  }

  .infoUnit {
    color: #adffd7;
    font-size: vh(16);
    font: SourceHanSansCN-Bold;
    margin-left: vw(4);
  }

  .infoSub {
    font-weight: 400;
    font-size: vh(10);
    color: #adffd7;
    line-height: vh(20);
  }
}
</style>